#include "StdAfx.h"

#include "ImageProcStepLibs.h"
#include "ImageProcDummyLib.h"
#include "DummyOne.h"
#include "DummyTwo.h"


const char * const ImageProcDummyLib::ImageProcStepDummyLibPathfileName = "c:\\wills\\xxx\\ImageProcStepDummyLib.dll";	//doesn't exist
const char * const ImageProcDummyLib::ImageProcStepDummyLibFileName = "ImageProcStepDummyLib.dll";
const char * const ImageProcDummyLib::ImageProcStepDummyLibVersion = "v1.0.0.0";
const char * const ImageProcDummyLib::ImageProcStepDummyLibFnCalcAvBrightness = DummyOne::FunctionNameDummyOne;


ImageProcDummyLib *ImageProcDummyLib::UnitTestCreateImageProcDummyLib()
{
	ImageProcDummyLib *rc = '\0';

	rc = new ImageProcDummyLib(ImageProcDummyLib::ImageProcStepDummyLibPathfileName);

	DummyOne *one = new DummyOne();
	if(rc->_LibApi->AddFunction(one) == false)
			delete one;
	DummyTwo *two = new DummyTwo();
	if(rc->_LibApi->AddFunction(two) == false)
			delete two;
	
	//.... add other functions

	rc->_LibApi->Validate();

	return rc;
}

ImageProcDummyLib::ImageProcDummyLib(const char *UnitTestName) :
	_LibApi('\0'),
	_UnitTestCreated(true),
	_UnitTestLibName(UnitTestName)
{
	_LibApi = new ImageProcStepLibAuto();
	_LibApi->SetLibNameVersion(ImageProcDummyLib::ImageProcStepDummyLibFileName, ImageProcDummyLib::ImageProcStepDummyLibVersion, ImageProcStepLibAuto::InterfaceVersion);
	_LibApi->SetLibOwnerDetails("Maximodex Limited", "Copyright 2012, Will Stott", "www.maximodex.com/ProductSupport/ImageCurator/ImageProcLibs/ImageProcSample");
	_LibApi->SetLibDescription("dummy - use only for testing - it doesn't do anything");

											//the above is equivalent of 
											//	IImageProcStepLibDyn * (*pfn)(void) = 0;
											//	*(FARPROC *)&pfn = ::GetProcAddress(rc->_hInstance, "CreateImageProcStepLib");
											//	if (pfn != NULL)
											//	{
											//		if ( pfn()->IsApiValid() && (pfn()->GetLibInterfaceVersion() == ImageProcStepLibAuto::InterfaceVersion))
											//		{
											//			rc->_LibApi = pfn()->GetLibApi();
											//		}
											//	}
}

ImageProcDummyLib::ImageProcDummyLib(void) :
	_LibApi('\0'),
	_UnitTestCreated(false),
	_UnitTestLibName(ImageProcStepLibs::BadDllPathFile)
{

}

ImageProcDummyLib::~ImageProcDummyLib(void)
{
	if (_LibApi != '\0')
		delete _LibApi;
	_LibApi = '\0';
	Delete();
}

void ImageProcDummyLib::SetLibNameForUnitTest(const char *name)
{ 
	if (_UnitTestCreated)
	{		
		_UnitTestLibName = name;
		_LibApi->SetName(name); 
	}
}			


bool ImageProcDummyLib::Run(const char *fnName, ProcParamsInputs *inputs, ProcParamsOutputs *outputs)
{
	bool rc = false;

	return rc;
}






